CC = ${COMPILER_PREFIX}gcc
CFLAGS = -c -Wall -I./res/raylib/include
LDFLAGS = -lpthread -L./res/raylib/lib/mac/ -lraylib
#LDFLAGS = -lpthread `pkg-config --libs raylib`
RAYLIB = -framework OpenGL -framework Cocoa -framework IOKit
LDFLAGS += $(RAYLIB)

SOURCES = raylib_test.c homework.c pub_lib.c homework1.c homework2.c \
 homework3.c shader.c \
 homework4.c \
 homework5.c ray_trace.c \
 homework6.c ray_trace.c bvh.c

OBJECTS = $(SOURCES:.c=.o)
PUBOBJS = pub_lib.o

RAYLIB_TEST = raylib_test
HOMEWORK = homework
HOMEWORK1 = homework1
HOMEWORK2 = homework2
HOMEWORK3 = homework3
HOMEWORK4 = homework4
HOMEWORK5 = homework5
HOMEWORK6 = homework6

all: $(SOURCES) $(RAYLIB_TEST) $(HOMEWORK) $(HOMEWORK1) \
	 $(HOMEWORK2) $(HOMEWORK3) $(HOMEWORK4) $(HOMEWORK5) \
	 $(HOMEWORK6)

$(RAYLIB_TEST): raylib_test.o $(PUBOBJS)
	$(CC) raylib_test.o $(PUBOBJS) -o $@ $(LDFLAGS) 

$(HOMEWORK): homework.o $(PUBOBJS)
	$(CC) homework.o $(PUBOBJS) -o $@ $(LDFLAGS)

$(HOMEWORK1): homework1.o $(PUBOBJS)
	$(CC) homework1.o $(PUBOBJS) -o $@ $(LDFLAGS)

$(HOMEWORK2): homework2.o $(PUBOBJS)
	$(CC) homework2.o $(PUBOBJS) -o $@ $(LDFLAGS)

$(HOMEWORK3): homework3.o shader.o $(PUBOBJS)
	$(CC) homework3.o shader.o $(PUBOBJS) -o $@ $(LDFLAGS)

$(HOMEWORK4): homework4.o
	$(CC) homework4.o -o $@ $(LDFLAGS)

$(HOMEWORK5): homework5.o ray_trace.o $(PUBOBJS)
	$(CC) homework5.o ray_trace.o $(PUBOBJS) -o $@ $(LDFLAGS)

$(HOMEWORK6): homework6.o ray_trace.o bvh.o $(PUBOBJS)
	$(CC) homework6.o ray_trace.o bvh.o $(PUBOBJS) -o $@ $(LDFLAGS)

.c.o:
	$(CC) $(CFLAGS) $< -o $@

clean:
	rm -f *.o $(RAYLIB_TEST) $(HOMEWORK) $(HOMEWORK1) \
	$(HOMEWORK2) $(HOMEWORK3) $(HOMEWORK4) $(HOMEWORK5) \
	$(HOMEWORK6)
